<template>
  <div :class="['tab-item',{current:cityId == cityInfo.cityId}]" @click="setCityId(cityInfo)">
    <span>{{cityInfo.cityName}}</span>
  </div>
</template>

<script>
  import {
    mapState,
    mapMutations
  } from 'vuex';

  export default {
    name: 'TabSub',
    props: {
      cityInfo: Object
    },
    computed: {
      ...mapState(['cityId'])
    },
    methods: {
      ...mapMutations(['selectCity']),
      setCityId(cityInfo) {
        this.selectCity(cityInfo);
      }
    }
  }
</script>

<style lang="scss" scoped="scoped">
  @import '~styles/mixins.scss';
  @import '~styles/variables.scss';

  .tab-item {
    @include vh-center;
    flex: 1;
    line-height: .5rem;
    font-size: .16rem;
    border-bottom: 2px solid transparent;
    box-sizing: border-box;

    &.current {
      color: $defaultGreen;
      border-bottom-color: $defaultGreen;
    }
  }
</style>
